//
// File: div.cpp
//
// MATLAB Coder version            : 5.4
// C/C++ source code generated on  : 25-Apr-2025 12:42:26
//

// Include Files
#include "div.h"
#include "freqDomainHRV_types.h"
#include "rt_nonfinite.h"
#include "coder_array.h"
#include <string.h>

// Function Definitions
//
// Arguments    : struct9_T *in1
//                const coder::array<double, 2U> &in2
// Return Type  : void
//
void b_binary_expand_op(struct9_T *in1, const coder::array<double, 2U> &in2)
{
  int i;
  int loop_ub;
  int stride_0_1;
  int stride_1_1;
  if (in2.size(1) == 1) {
    i = in1->wav.hrv.LFHF.size(1);
  } else {
    i = in2.size(1);
  }
  in1->wav.hrv.nLF.set_size(1, i);
  stride_0_1 = (in1->wav.hrv.LFHF.size(1) != 1);
  stride_1_1 = (in2.size(1) != 1);
  if (in2.size(1) == 1) {
    loop_ub = in1->wav.hrv.LFHF.size(1);
  } else {
    loop_ub = in2.size(1);
  }
  for (i = 0; i < loop_ub; i++) {
    in1->wav.hrv.nLF[i] =
        in1->wav.hrv.LFHF[i * stride_0_1] / in2[i * stride_1_1];
  }
}

//
// Arguments    : coder::array<double, 2U> &in1
//                const struct9_T *in2
//                const coder::array<double, 1U> &in3
// Return Type  : void
//
void binary_expand_op(coder::array<double, 2U> &in1, const struct9_T *in2,
                      const coder::array<double, 1U> &in3)
{
  coder::array<double, 2U> b_in2;
  int aux_0_1;
  int aux_1_1;
  int i;
  int loop_ub;
  int stride_1_1;
  int unnamed_idx_1;
  unnamed_idx_1 = in3.size(0);
  in1.set_size(449, unnamed_idx_1);
  for (i = 0; i < unnamed_idx_1; i++) {
    for (int i1{0}; i1 < 449; i1++) {
      in1[i1 + 449 * i] = in2->wav.global.psd[i1];
    }
  }
  if (in1.size(1) == 1) {
    i = in2->wav.psd.size(1);
  } else {
    i = in1.size(1);
  }
  b_in2.set_size(449, i);
  unnamed_idx_1 = (in2->wav.psd.size(1) != 1);
  stride_1_1 = (in1.size(1) != 1);
  aux_0_1 = 0;
  aux_1_1 = 0;
  if (in1.size(1) == 1) {
    loop_ub = in2->wav.psd.size(1);
  } else {
    loop_ub = in1.size(1);
  }
  for (i = 0; i < loop_ub; i++) {
    for (int i1{0}; i1 < 449; i1++) {
      b_in2[i1 + 449 * i] =
          in2->wav.psd[i1 + 449 * aux_0_1] / in1[i1 + 449 * aux_1_1];
    }
    aux_1_1 += stride_1_1;
    aux_0_1 += unnamed_idx_1;
  }
  in1.set_size(449, b_in2.size(1));
  loop_ub = b_in2.size(1);
  for (i = 0; i < loop_ub; i++) {
    for (int i1{0}; i1 < 449; i1++) {
      in1[i1 + 449 * i] = b_in2[i1 + 449 * i];
    }
  }
}

//
// Arguments    : struct9_T *in1
//                const coder::array<double, 2U> &in2
// Return Type  : void
//
void binary_expand_op(struct9_T *in1, const coder::array<double, 2U> &in2)
{
  int i;
  int loop_ub;
  int stride_0_1;
  int stride_1_1;
  if (in2.size(1) == 1) {
    i = in1->wav.hrv.aHF.size(1);
  } else {
    i = in2.size(1);
  }
  in1->wav.hrv.nHF.set_size(1, i);
  stride_0_1 = (in1->wav.hrv.aHF.size(1) != 1);
  stride_1_1 = (in2.size(1) != 1);
  if (in2.size(1) == 1) {
    loop_ub = in1->wav.hrv.aHF.size(1);
  } else {
    loop_ub = in2.size(1);
  }
  for (i = 0; i < loop_ub; i++) {
    in1->wav.hrv.nHF[i] =
        in1->wav.hrv.aHF[i * stride_0_1] / in2[i * stride_1_1];
  }
}

//
// Arguments    : struct9_T *in1
// Return Type  : void
//
void binary_expand_op(struct9_T *in1)
{
  coder::array<double, 2U> b_in1;
  int i;
  int loop_ub;
  int stride_0_1;
  int stride_1_1;
  if (in1->wav.hrv.aHF.size(1) == 1) {
    i = in1->wav.hrv.LFHF.size(1);
  } else {
    i = in1->wav.hrv.aHF.size(1);
  }
  b_in1.set_size(1, i);
  stride_0_1 = (in1->wav.hrv.LFHF.size(1) != 1);
  stride_1_1 = (in1->wav.hrv.aHF.size(1) != 1);
  if (in1->wav.hrv.aHF.size(1) == 1) {
    loop_ub = in1->wav.hrv.LFHF.size(1);
  } else {
    loop_ub = in1->wav.hrv.aHF.size(1);
  }
  for (i = 0; i < loop_ub; i++) {
    b_in1[i] =
        in1->wav.hrv.LFHF[i * stride_0_1] / in1->wav.hrv.aHF[i * stride_1_1];
  }
  in1->wav.hrv.LFHF.set_size(1, b_in1.size(1));
  loop_ub = b_in1.size(1);
  for (i = 0; i < loop_ub; i++) {
    in1->wav.hrv.LFHF[i] = b_in1[i];
  }
}

//
// Arguments    : coder::array<double, 1U> &in1
//                const coder::array<double, 1U> &in2
// Return Type  : void
//
void rdivide(coder::array<double, 1U> &in1, const coder::array<double, 1U> &in2)
{
  coder::array<double, 1U> b_in1;
  int i;
  int loop_ub;
  int stride_0_0;
  int stride_1_0;
  if (in2.size(0) == 1) {
    i = in1.size(0);
  } else {
    i = in2.size(0);
  }
  b_in1.set_size(i);
  stride_0_0 = (in1.size(0) != 1);
  stride_1_0 = (in2.size(0) != 1);
  if (in2.size(0) == 1) {
    loop_ub = in1.size(0);
  } else {
    loop_ub = in2.size(0);
  }
  for (i = 0; i < loop_ub; i++) {
    b_in1[i] = in1[i * stride_0_0] / in2[i * stride_1_0];
  }
  in1.set_size(b_in1.size(0));
  loop_ub = b_in1.size(0);
  for (i = 0; i < loop_ub; i++) {
    in1[i] = b_in1[i];
  }
}

//
// File trailer for div.cpp
//
// [EOF]
//
